package com.system.business.controller;

import com.system.business.been.IntervalPlan;
import com.system.business.service.IntervalPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * @author 林
 */
@RestController
@RequestMapping("/intervalPlan")
public class IntervalPlanController {
    @Autowired
    private IntervalPlanService intervalPlanService;

    @PostMapping("/save")
    public boolean saveHandle(@RequestBody IntervalPlan intervalPlan){
        return intervalPlanService.saveIntervalPlan(intervalPlan);
    }

    @DeleteMapping("/del/{id}")
    public boolean deleteHandle(@PathVariable("id") int id){
        return intervalPlanService.removeIntervalPlanById(id);
    }

    @PutMapping("/update")
    public boolean updateHandle(@RequestBody IntervalPlan intervalPlan){
        return intervalPlanService.modifyIntervalPlan(intervalPlan);
    }

    @GetMapping("/get/{id}")
    public IntervalPlan getHandle(@PathVariable("id") int id){
        return intervalPlanService.getIntervalPlanById(id);
    }

    @GetMapping("/get/list")
    public List<IntervalPlan> listHandle(){
        return intervalPlanService.listAllIntervalPlans();
    }
}
